﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UniRlv.Utility
{
    /// <summary>
    /// 实现单例模式
    /// </summary>
    /// public static yourclass GetInstance()
    /// {
    ///     return Singleton<yourClass>.GetInstance();
    /// }
    /// <typeparam name="T"></typeparam>
    public class Singleton<T> where T: class, new()
    {
        private static T _instance;
        private static readonly object objLock = new object();

        public static T GetInstance()
        {
            if (_instance == null)
	        {
		        lock (objLock)
	            {
                    _instance = new T();
	            }
	        }

            return _instance;
        }
    }
}
